Skip to content

fix(contexts): detect the browser's implicit context and create targets in it without id - #627

Merged
route merged 1 commit into
mainfrom
fix/implicit-browser-context
Sep 1, 2026
Merged

fix(contexts): detect the browser's implicit context and create targets in it without id#627
route merged 1 commit into
mainfrom
fix/implicit-browser-context

Conversation

@route

@route route commented Sep 1, 2026

Copy link
Copy Markdown
Member

Connecting to a browser that came up with its own startup window, raised Failed to find browser context with id on the first create_page. That window lives in the browser's implicit context, which Chrome below 145 refuses to address by id.

We now detect the implicit context up front as the context holding targets that Target.getBrowserContexts doesn't report, since that reports only contexts created through Target.createBrowserContext, and create targets in it the way Chrome expects, by omitting browserContextId. Target.getBrowserContexts covers every client driving the browser, so a context another Ferrum created in it is never mistaken for the implicit one.

Ferrum::Context#implicit? tells the two apart. The implicit context is never disposed, so #reset leaves such a browser's startup window and cookies alone; launch the remote browser with --no-startup-window to get a context of our own that #reset can clean up.

Closes #578

…ts in it without id

Connecting to a browser that came up with its own startup window, raised `Failed to find browser context with id` on the first `create_page`. That window lives in the browser's implicit context, which Chrome below 145 refuses to address by id.

We now detect the implicit context up front as the context holding targets that `Target.getBrowserContexts` doesn't report, since that reports only contexts created through `Target.createBrowserContext`, and create targets in it the way Chrome expects, by omitting `browserContextId`. `Target.getBrowserContexts` covers every client driving the browser, so a context another Ferrum created in it is never mistaken for the implicit one.

`Ferrum::Context#implicit?` tells the two apart. The implicit context is never disposed, so `#reset` leaves such a
browser's startup window and cookies alone; launch the remote browser with --no-startup-window to get a context of
our own that `#reset` can clean up.

Closes #578
@route
route force-pushed the fix/implicit-browser-context branch from 245233a to 4e3c3ec Compare September 1, 2026 16:37
@route
route merged commit 47e93cf into main Sep 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential regression in implicit browser context handling with flatten: false and Browserless

1 participant